package com.youme.tools.cg.db.enums;

public enum MySqlDataType {
  /** bigint goto Long */
  BIGINT("bigint", "Long"),
  /** blob goto String */
  BLOB("blob", "String"),
  /** char goto String */
  CHAR("char", "String"),
  /** datetime goto String */
  DATETIME("datetime", "String"),
  /** decimal goto java.math.BigDecimal */
  DECIMAL("decimal", "java.math.BigDecimal"),
  /** double goto java.math.BigDecimal */
  DOUBLE("double", "java.math.BigDecimal"),
  /** enum goto String */
  ENUM("enum", "String"),
  /** float goto java.math.BigDecimal */
  FLOAT("float", "java.math.BigDecimal"),
  /** int goto Integer */
  INT("int", "Integer"),
  /** longblob goto String */
  LONGBLOB("longblob", "String"),
  /** longtext goto String */
  LONGTEXT("longtext", "String"),
  /** mediumblob goto String */
  MEDIUMBLOB("mediumblob", "String"),
  /** mediumtext goto String */
  MEDIUMTEXT("mediumtext", "String"),
  /** set goto String */
  SET("set", "String"),
  /** smallint goto Integer */
  SMALLINT("smallint", "Integer"),
  /** text goto String */
  TEXT("text", "String"),
  /** time goto String */
  TIME("time", "String"),
  /** timestamp goto String */
  TIMESTAMP("timestamp", "String"),
  /** tinyint goto Integer */
  TINYINT("tinyint", "Integer"),
  /** varchar goto String */
  VARCHAR("varchar", "String");

  /** 数据库类型 */
  private String dbType;
  /** Java类型 */
  private String javaType;

  /**
   * 
   * 构造函数
   * 
   * @param dbType 数据库类型
   * @param javaType Java类型
   */
  private MySqlDataType(String dbType, String javaType) {
    this.dbType = dbType;
    this.javaType = javaType;
  }

  /**
   * 根据数据库类型获得Java类型
   * 
   * @Title: getJavaTypeByDbType
   * @Description: 根据数据库类型获得Java类型
   * @param dbType 数据库类型
   * @return Java类型
   */
  public static String getJavaTypeByDbType(String dbType) {
    switch (dbType) {
      case "bigint":
        return BIGINT.getJavaType();
      case "blob":
        return BLOB.getJavaType();
      case "char":
        return CHAR.getJavaType();
      case "datetime":
        return DATETIME.getJavaType();
      case "decimal":
        return DECIMAL.getJavaType();
      case "double":
        return DOUBLE.getJavaType();
      case "enum":
        return ENUM.getJavaType();
      case "float":
        return FLOAT.getJavaType();
      case "int":
        return INT.getJavaType();
      case "longblob":
        return LONGBLOB.getJavaType();
      case "longtext":
        return LONGTEXT.getJavaType();
      case "mediumblob":
        return MEDIUMBLOB.getJavaType();
      case "mediumtext":
        return MEDIUMTEXT.getJavaType();
      case "set":
        return SET.getJavaType();
      case "smallint":
        return SMALLINT.getJavaType();
      case "text":
        return TEXT.getJavaType();
      case "time":
        return TIME.getJavaType();
      case "timestamp":
        return TIMESTAMP.getJavaType();
      case "tinyint":
        return TINYINT.getJavaType();
      case "varchar":
        return VARCHAR.getJavaType();
      default:
        return null;
    }
  }

  /**
   * 获取：数据库类型
   */

  public String getDbType() {
    return dbType;
  }

  /**
   * 获取：Java类型
   */

  public String getJavaType() {
    return javaType;
  }
}
